package cn.stylefeng.guns.modular.gridsystem.mqtt;

import cn.stylefeng.guns.modular.gridsystem.config.MqttClientConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @author ssy
 * @date 2023/3/7 13:48
 */
@Component
@Slf4j
public class MyMqttInit implements CommandLineRunner {

    @Autowired
    private MqttClientConfig clientConfig;

    @Autowired
    private MyMqttClient myMqttClient;

    @Override
    public void run(String... args) throws Exception {
        if(clientConfig.isEnable()){
            myMqttClient.connect();
        }
    }
}
